package wechat.base.snd;

import org.eclipse.xtext.xbase.lib.Exceptions;
import org.json.JSONObject;
import wechat.base.snd.WCServiceApp;
import wechat.base.snd.WCServiceAppMessage;
import wechat.base.snd.encoding.JsonPut;
import wechat.base.snd.util.ExecPost;

@SuppressWarnings("all")
public class WCTextMessage extends WCServiceAppMessage {
  public WCTextMessage(final WCServiceApp sa) {
    this.app = sa;
    JsonPut _jsonPut = new JsonPut();
    this.content = _jsonPut;
  }
  
  public void withContent(final String contnt) {
    try {
      final JSONObject text = new JSONObject();
      text.put("content", contnt);
      this.content.putObj("text", text);
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }
  
  public void withMsgType(final String msgType) {
    this.content.putObj("msgtype", msgType);
  }
  
  public void send2Users(final Iterable<String> users) {
    for (final String usr : users) {
      {
        this.content.putObj("touser", usr);
        ExecPost.excuteJsonPost(this.app.getTestApplicationUrl(), this.content.toString());
      }
    }
  }
}
